package log4j;

import org.apache.log4j.ConsoleAppender;
import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout;

import static log4j.Log4JUtils.newConsoleAppender;
import static log4j.Log4JUtils.newPatternLayout;

public class Log4JProgrammaticallyTest {

    public static void main(String[] args) {
        // logger
        Logger logger = Logger.getLogger("a.b.c");
        logger.setAdditivity(false);
//        // appender
        ConsoleAppender appender = newConsoleAppender();
        logger.addAppender(appender);
        // layout
        PatternLayout layout = newPatternLayout("%-5p %d %C %M: %m\n");
//        PatternLayout layout = newPatternLayout("%r [%t] %-5p %c %x - %m%n");
        appender.setLayout(layout);

        // TEST
        logger.fatal("!");
        logger.warn("!");
        logger.warn("!");
        logger.warn("!");
    }
}
